//Integer currPage,Integer pageSize,String memberId,String queryStatus
var member;
var currPage=0;
var pageSize=5;
var queryStatus=GetQueryString("queryStatus");
var memberId;
$(function(){
    $('.form_datetime').datetimepicker({
		language:'zh-CN',
		format: 'yyyy-MM-dd',
		autoclose: true,
		todayBtn: true,
		pickerPosition:'bottom-left',
		startView:2,
		minView:2,
	});
	if(!queryStatus){
		queryStatus=0;
	}
	//修改页面订单的状态标签颜色
	$(".state > a").eq(0).removeClass("red");
	$(".state > a").eq(queryStatus).addClass("red");
	
	$(".last  a").eq(0).removeClass("red");
	$(".last  a").eq(queryStatus).addClass("red");
	member=getEntity("memberInfo");
	if(member){
		$("#mImg").attr("src",baseFile + member.mImg);
		memberId=member.mId;
	}
	init(memberId,queryStatus,pageSize,currPage);
	
	$(".all_order .right .order_info form select[name=queryStatus]").on('input propertychange',function(){
        var result = $(this).val();
        if(result == '6'){
        	 $(".all_order .right .order_info form select[name=orderStatus]").find("option[value='3']").attr("selected",true);
         	$(".all_order .right .order_info form select[name=commentStatus]").find("option[value='1']").attr("selected",true); 
        }
	});

	$(".all_order .right .order_info form select[name=orderStatus]").on('input propertychange',function(){
        var result = $(this).val();
        if(result == '3'){
        	$(".all_order .right .order_info form select[name=queryStatus]").find("option[value='6']").attr("selected",true); 
       	 $(".all_order .right .order_info form select[name=orderStatus]").find("option[value='3']").attr("selected",true);
        }else{
        	$(".all_order .right .order_info form select[name=queryStatus]").find("option[value='4']").attr("selected",true); 
        	$(".all_order .right .order_info form select[name=commentStatus]").find("option[value='0']").attr("selected",true);
        }
	});
	$(".all_order .right .order_info form select[name=commentStatus]").on('input propertychange',function(){
        var result = $(this).val();
        if(result == '1'){
        	$(".all_order .right .order_info form select[name=queryStatus]").find("option[value='6']").attr("selected",true); 
        	$(".all_order .right .order_info form select[name=orderStatus]").find("option[value='3']").attr("selected",true);
        }else{
        	$(".all_order .right .order_info form select[name=queryStatus]").find("option[value='4']").attr("selected",true); 
        	$(".all_order .right .order_info form select[name=orderStatus]").find("option[value='0']").attr("selected",true);
        }
	});
	//点击下一页事件
	$("#page").click(function(){
		currPage=$(".pageItemActive").attr("page-data");
		init(memberId,queryStatus,pageSize,currPage);
	});
	//高级搜索
	$("#highLevelSearch").click(function(){
	    initPage();
	    $(".state > a").each(function(){
			if($(this).attr("class")  == "red"){
				$(this).removeClass("red");
			}
		});
		var commentStatus = $(".all_order .right .order_info form select[name=commentStatus]").find("option:selected").val();
	    var queryStatus = $(".all_order .right .order_info form select[name=queryStatus]").find("option:selected").val();
	    var orderStatus = $(".all_order .right .order_info form select[name=orderStatus]").find("option:selected").val();
	    var likeStr = $(".all_order .right .order_info form >p input[name=likeStr]").val();
	    $(".state > a").eq(queryStatus).addClass("red");
	    
	  
	    $.ajax({
			type:"post",
			url:rootPath+"/order/orderList",
			data:{'memberId':memberId,
				  'queryStatus':queryStatus,
				  'orderStatus':orderStatus,
				  'commentStatus':commentStatus,
				  'likeStr':likeStr,
				  'pageSize':pageSize,
				  'currPage':currPage,
				  'startTime':$("input[name='startTime']").val(),
				  'endTime':$("input[name='endTime']").val()
			},
			success:function(data){
				$("#orderList").empty();
				var orderList=data.data;
				$.each(orderList,function(i,item){
					var productList=item.products;
					var strHeader='';
					if(productList.length > 1){
						strHeader='<div class="multiple"><span class="order_number">订单号：<i class="three">'+item.orderId+'</i></span>';
						strHeader+=createMultiHtml(item,productList);						
					}else if(productList.length == 1){
						strHeader='<div><span class="order_number">订单号：<i class="three">'+item.orderId+'</i></span>';
						$.each(productList,function(j,itemIn){
							strHeader+=createSingleHtml(item,itemIn);
						});
					}else{}	
					
					strHeader +='</div>';
					$("#orderList").append(strHeader);
				});
			}
		});
	    $(".all_order .right .order_info form >p input[name=likeStr]").val(likeStr);
	});
	//取消删除订单
	$(document).on("click",".all_order .right .order_info .items li > div > div > div .cacelOrdelOrder",function(){//由于a标签是动态生成的,onclick事件传入的参数无法
		var $orderId = $(this).attr("orderid");
		var $status = $(this).attr("status");		
		//alert("$status: " + $status +" $orderId: "+$orderId);
		cancelOrDeleteOrder($orderId,$status);
	});
	//取消删除订单
	$(document).on("click",".all_order .right .order_info .multiple .mul .cacelOrdelOrder",function(){
		var $orderId = $(this).attr("orderid");
		var $status = $(this).attr("status");		
		//alert("$status: " + $status +" $orderId: "+$orderId);
		cancelOrDeleteOrder($orderId,$status);
	});
	
	//确认收货
	$(document).on("click",".all_order .right .order_info .items li > div > div > div .confirmReceiptOrder",function(){//由于a标签是动态生成的,onclick事件传入的参数无法
		var $orderId = $(this).attr("orderid");
		confirmReceiptOrder($orderId);
	});
	//确认收货
	$(document).on("click",".all_order .right .order_info .multiple .mul .confirmReceiptOrder",function(){
		var $orderId = $(this).attr("orderid");	
		confirmReceiptOrder($orderId);
	});
	$(document).on("click",".all_order .right .order_info .items .delete > a",function(){
		var $orderId = $(this).attr("orderid");
		var $status = $(this).attr("status");		
		//alert("$status: " + $status +" $orderId: "+$orderId);
		cancelOrDeleteOrder($orderId,$status);
	});

});
function init(memberId,queryStatus,pageSize,currPage){
	var commentStatus = $(".all_order .right .order_info form select[name=commentStatus]").find("option:selected").val();
    var queryStatus = $(".all_order .right .order_info form select[name=queryStatus]").find("option:selected").val();
    var orderStatus = $(".all_order .right .order_info form select[name=orderStatus]").find("option:selected").val();
    var likeStr = $(".all_order .right .order_info form >p input[name=likeStr]").val();
	$.ajax({
		type:"post",
		url:rootPath+"/order/orderList",
		data:{'memberId':memberId,
			  'queryStatus':queryStatus,
			  'orderStatus':orderStatus,
			  'commentStatus':commentStatus,
			  'pageSize':pageSize,
			  'currPage':currPage},
		dataType:"JSON",
		success:function(data){
			$("#orderList").empty();
			var orderList=data.data;
			console.log(orderList)
			$.each(orderList,function(i,item){
				var productList=item.products;
				var strHeader='';
				if(productList.length > 1){
					strHeader='<div class="multiple"><span class="order_number">订单号：<i class="three">'+item.orderId+'</i></span>';
					strHeader+=createMultiHtml(item,productList);
					/*$.each(productList,function(j,itemIn){
						strHeader+=createMultiHtml(item,itemIn);
					})*/
				}else if(productList.length == 1){
					strHeader='<div><span class="order_number">订单号：<i class="three">'+item.orderId+'</i></span>';
					$.each(productList,function(j,itemIn){
						strHeader+=createSingleHtml(item,itemIn);
					});
				}else{}				
				
				strHeader +='</div>';
				$("#orderList").append(strHeader);
			});
		}	
	});
}

//刷新订单列表
function reloadOrderList(queryStatus){
	window.location.href=rootPath + '/order/orderPage?queryStatus=' + queryStatus;
}
//删除或取消
function cancelOrDeleteOrder($orderId,$status){ //订单取消订单 status 0:取消订单 ;1：删除订单
	var url =  rootPath + "/order/cancelOrDeleteOrder";
	var confirmInfo = $status == 0 ?"确认要取消订单吗？":"确认要删除订单吗？";
    var alarmInfoSuccess = $status == 0 ?"订单取消成功!":"订单删除成功!";
    var alarmInfoFail = $status == 0 ?"订单取消失败!":"订单删除失败!";
	layer.confirm(confirmInfo,{skin: 'layui-layer-red ',offset: ['40%', '40%']},function(index){

		var result = CommnUtil.ajax(url,
									{"orderId":$orderId,
								    "status":$status},
									"json");
		if(result.resultSuccess){
			 layer.msg(alarmInfoSuccess,{icon:1,skin: 'layui-layer-red ',offset: ['40%', '45%']});	
	         Pause(this,6000);//调用暂停函数
		     this.NextStep=function(){
				 reloadOrderList(queryStatus); //当前订单页面
		     }
		}else{
			 layer.msg(alarmInfoFail,{icon:2,skin: 'layui-layer-red ',offset: ['40%', '45%']});	
	         Pause(this,6000);//调用暂停函数
		     this.NextStep=function(){
				 reloadOrderList(queryStatus); //当前订单页面
		     }
		}
	});

}

//确认收货
function  confirmReceiptOrder($orderId){
	var url =  rootPath + "/order/confirmReceiptOrder";
	layer.confirm("要确认收货吗？",{skin: 'layui-layer-red ',offset: ['40%', '40%']},function(index){

		var result = CommnUtil.ajax(url,
				{"orderId":$orderId},
				"json");
		if (result.resultSuccess) {
			layer.msg("确认收货成功", {
				icon : 1,
				skin : 'layui-layer-red ',
				offset : [ '40%', '45%' ]
			});
			Pause(this, 6000);// 调用暂停函数
			this.NextStep = function() {
				reloadOrderList('4'); //待评价页面
			}

		} else {
			layer.msg("确认收货失败", {
				icon : 2,
				skin : 'layui-layer-red ',
				offset : [ '40%', '45%' ]
			});
			Pause(this, 6000);//调用暂停函数
			this.NextStep = function() {
				 reloadOrderList(queryStatus); //待收货订单页面
			}
		}
	});
	
}
function createSingleHtml(item,itemIn){
		var str='';
		var status='';
		var statusDetail='';
		var comment='';
		var payStatus = item.payStatus;
		var shipStatus = item.shipStatus;
		var isComment = item.isComment;
		var isValid = item.isValid;
		var detailUrl = rootPath + "/order/order_details?orderId="+item.orderId; //订单详情页
		var commentUrl = rootPath + "/order/comment?orderId="+item.orderId+"&productId="+itemIn.productId; //订单评价
		var addCommentUrl = rootPath + "/order/add_comment?orderId="+item.orderId+"&productId="+itemIn.productId; //订单追加评价
		var orderCardsPayUrl = rootPath + "/order/order_card_pay?orderId="+item.orderId; //付款页面
		var expressUrl ='https://m.kuaidi100.com/index_all.html?type='+item.expressName+'&postid=' + item.expressCode;
	//	var delOrderUrl = rootPath + "/order/cancelOrDeleteOrder?status=1&orderId="+item.orderId; //删除订单 status 0:取消订单 ;1：删除订单
	//	var cancelOrderUrl = rootPath + "/order/cancelOrDeleteOrder?status=0&orderId="+item.orderId; //取消订单 status 0:取消订单 ;1：删除订单
		var outDelete ='';
		var sDetail ='';
		var $unitPrice ="";
		var allp1=parseFloat(itemIn.discountMarketPrice);
		var allp2=parseFloat(itemIn.marketPrice);
		if(itemIn.discountMarketPrice){
			$unitPrice = '<div><!--<s>'+itemIn.marketPrice+'</s><br />--><span><i class="red">￥'+allp1.toFixed(2)+'</i></span></div>';
		}else{
			$unitPrice = '<div><!--<s>'+itemIn.marketPrice+'</s><br />--><span><i class="red">￥'+allp2.toFixed(2)+'</i></span></div>';
		}
		
		if(payStatus == '3' && shipStatus =='0' && isComment=='0' && isValid=='0'){
			statusDetail ='等待买家付款'; //onclick=cancelOrDeleteOrder('+item.orderId+","+"0"+')
			status='<div><!--<div>'+'等待买家付款'+'</div>--><a href="'+detailUrl+'" target="_blank">订单详情</a><br /><a href="javascript:void(0)" orderId="'+item.orderId+'" status="0"  class="cacelOrdelOrder"  target="_self">取消订单</a><br /><a href="'+orderCardsPayUrl+'" target="_blank" >立即付款</a>';
			sDetail = 'style="margin-left: 57%;"'; 
		}else if((payStatus == '1' || payStatus =='6')  && shipStatus =='0' && isComment=='0' && isValid=='0'){
			statusDetail ='等待卖家发货';
		//	status='<div><!--<div>'+'等待卖家发货'+'</div>--><a href="'+detailUrl+'" target="_blank">订单详情</a><br /><a href="" target="_blank">提醒发货</a></div>';
			status='<div><!--<div>'+'等待卖家发货'+'</div>--><a href="'+detailUrl+'" target="_blank">订单详情</a><br /></div>';
			sDetail = 'style="margin-left: 57%;"';
		}else if((payStatus == '1' || payStatus =='6') &&( shipStatus =='1' || shipStatus == '2')&& isComment=='0' && isValid=='0'){
			statusDetail ='卖家已发货';
			status='<div><!--<div>'+'卖家已发货'+'</div>--><a href="'+detailUrl+'" target="_blank">订单详情</a><br /><a href="'+expressUrl+'" target="_blank">查看物流</a><br /><a href="javascript:void(0)"   orderId="'+item.orderId+'" class="confirmReceiptOrder" target="_blank">确认收货</a>';
			sDetail = 'style="margin-left: 57%;"';
		}else if((payStatus == '1' || payStatus =='6') && shipStatus =='5' && isComment=='0' && isValid=='0'){
			statusDetail ='交易成功';
			status='<div><!--<div>'+'交易成功'+'</div>--><a href="'+detailUrl+'" target="_blank">订单详情</a><br /><a  orderId="'+item.orderId+'" status="1"  class="cacelOrdelOrder" target="_self">删除订单</a><br /><a  href="'+expressUrl+'" target="_blank">查看物流</a>';
			outDelete ='<span class="r delete"><a orderId="'+item.orderId+'" status="1"  class="cacelOrdelOrder" target="_self" title="删除订单"><img src="'+rootPath+'/images/delete1.png" alt="" /></a></span>';
			sDetail = 'style="margin-left: 52%;"';
		}else if((payStatus == '1' || payStatus =='6') && shipStatus =='5' && isComment=='1' && isValid=='0'){
			statusDetail ='交易成功';
			status='<div><!--<div>'+'交易成功'+'</div>--><a href="'+detailUrl+'"  target="_blank">订单详情</a><br /><a  orderId="'+item.orderId+'" status="1"  class="cacelOrdelOrder" target="_self">删除订单</a><br /><a href=""><a  href="'+expressUrl+'" target="_blank">查看物流</a>';
			outDelete ='<span class="r delete"><a orderId="'+item.orderId+'" status="1"  class="cacelOrdelOrder" target="_self" title="删除订单"><img src="'+rootPath+'/images/delete1.png" alt="" /></a></span>';
			sDetail = 'style="margin-left: 52%;"';
		}else if(/*payStatus == '3' && shipStatus =='0' && isComment=='0' &&*/ isValid=='1'){
			statusDetail ='交易关闭';
			status='<div><!--<div>'+'交易关闭'+'</div>--><a href="'+detailUrl+'" target="_blank">订单详情</a><br /><a href="javascript:;" orderId="'+item.orderId+'" status="1"  class="cacelOrdelOrder"  target="_self">删除订单</a>';
			outDelete ='<span class="r delete"><a orderId="'+item.orderId+'" status="1"  class="cacelOrdelOrder" target="_self" title="删除订单"><img src="'+rootPath+'/images/delete1.png" alt="" /></a></span>';
			sDetail = 'style="margin-left: 52%;"';
		}else{
			outDelete ='<span class="r delete" ><a orderId="'+item.orderId+'" status="1"  class="cacelOrdelOrder" target="_self" title="删除订单"><img src="'+rootPath+'/images/delete1.png" alt="" /></a></span>';		
			sDetail = 'style="margin-left: 52%;"';
		}
		var price ="";
		if(itemIn.discountMarketPrice){
			price = itemIn.discountMarketPrice;
		}else{
			price = itemIn.marketPrice;
		}
		var productDetailUrl = rootPath + "/goods/queryGoodsDetail?id=" + itemIn.productId;
		var goods_sku_info = '';
		if(itemIn.goods_sku_info){
			goods_sku_info = itemIn.goods_sku_info;
		}else{
			goods_sku_info ='无规格信息';
		}
		//判断订单详细中商品评论状态
		if((payStatus == '1' || payStatus =='6') && shipStatus =='5' && itemIn.isComment=='0' && isValid=='0'){
			comment ='<div class="comment"><a href="'+commentUrl+'" target="_blank">立即评价</a></div>';
			
		}else if((payStatus == '1' || payStatus =='6') && shipStatus =='5' && itemIn.isComment=='1' && isValid=='0'){
			comment ='<div class="comment"><a href="'+addCommentUrl+'" target="_blank">追加评价</a></div>';
				
		}
		var picture  = rootPath+"/images/defualt.png";
		if(itemIn.picture){
			picture = itemIn.picture;
		}
		comment += "</div></div>";
		var price01=parseFloat(item.totalAmount);
		var  shipMoney=parseFloat(item.shipMoney);
		str='<div class="items f12">'
				+'<p class="nine">'
					+'<span class="nine">'+item.orderCreatTime+'</span>'
					+'<span class="three shop">'+item.shopName+'</span>'
					+'<span class="order status" style="margin-left: 57%;">'+statusDetail+'</span>'
					+outDelete
				+'</p>'
				+'<ul class="clearfix">'
					+'<li>'
						+'<div class="name clearfix">'
							 +'<a href="'+productDetailUrl+'"  target="_blank"><img style="width:80px; height:80px" src="'+picture+'" alt="" /></a>'
							 +'<div class="r">'
							      +'<a href="'+productDetailUrl+'"  target="_blank">'+itemIn.productName+'</a>'
								  +'<p class="f12 nine"><span>' + goods_sku_info + '</span></p>'
							 +'</div>'
						+'</div>'
						+$unitPrice
						+'<div>'+itemIn.quantity+'</div><div>'+item.memberName+'</div>'
						+'<div class="money"><span class="price">￥'+price01.toFixed(2)+'</span><br /><span>(含运费：￥'+shipMoney.toFixed(2)+')</span></div>'
						+'<div>'
						     +'<div>'+status+'</div>'
						+'</div>'
						+comment
					+'</li>'
				+'</ul>'
			+'</div>';
		return str;
};

function createMultiHtml(item,productList){
	var status='';
	var statusDetail='';
	var payStatus = item.payStatus;
	var shipStatus = item.shipStatus;
	var isComment = item.isComment;
	var isValid = item.isValid;
	var detailUrl = rootPath + "/order/order_details?orderId="+item.orderId; //订单详情页
	var orderCardsPayUrl = rootPath + "/order/order_card_pay?orderId="+item.orderId; //订单支付
	var delOrderUrl = rootPath + "/order/cancelOrDeleteOrder?status=1&orderId="+item.orderId; //删除订单 status 0:取消订单 ;1：删除订单
	var cancelOrderUrl = rootPath + "/order/cancelOrDeleteOrder?status=0&orderId="+item.orderId; //取消订单 status 0:取消订单 ;1：删除订单
	var expressUrl ='https://m.kuaidi100.com/index_all.html?type='+item.expressName+'&postid=' + item.expressCode; //type=韵达&postid=1901777313123
	var height = productList.length * 120;
	height="height:"+height+"px;";
	var outDelete ='';
	var sDetail ='';
	if(payStatus == '3' && shipStatus =='0' && isComment=='0' && isValid=='0'){
		statusDetail ='等待买家付款';
		status='<div class="l mul" style="'+ height  +'"><!--<div>'+'等待买家付款'+'</div>--><div><a href="'+detailUrl+'" target="_blank">订单详情</a><br /><a href="javascript:;" orderId="'+item.orderId+'" status="0"  class="cacelOrdelOrder"  target="_self">取消订单</a><br /><a href="'+orderCardsPayUrl+'" target="_blank">立即付款</a></div></div>';
	    sDetail = 'style="margin-left: 57%;"';
	}else if((payStatus == '1' || payStatus =='6')  && shipStatus =='0' && isComment=='0' && isValid=='0'){
		statusDetail ='等待卖家发货';
	//	status='<div class="l mul"  style="'+ height  +'"><!--<div>'+'等待卖家发货'+'</div>--><div><a href="'+detailUrl+'" target="_blank">订单详情</a><br /><a href="" target="_blank">提醒发货</a></div>';
		status='<div class="l mul"  style="'+ height  +'"><!--<div>'+'等待卖家发货'+'</div>--><div><a href="'+detailUrl+'" target="_blank">订单详情</a></div>';
		sDetail = 'style="margin-left: 57%;"';
	}else if((payStatus == '1' || payStatus =='6') &&( shipStatus =='1' || shipStatus == '2')&& isComment=='0' && isValid=='0'){
		statusDetail ='卖家已发货';
		status='<div class="l mul"  style="'+ height  +'"><!--<div>'+'卖家已发货'+'</div>--><div><a href="'+detailUrl+'" target="_blank">订单详情</a><br /><a href="'+expressUrl+'" target="_blank">查看物流</a><br /><a href="javascript:void(0)"   orderId="'+item.orderId+'" class="confirmReceiptOrder" target="_blank">确认收货</a></div></div>';
		sDetail = 'style="margin-left: 57%;"';
	}else if((payStatus == '1' || payStatus =='6') && shipStatus =='5' && isComment=='0' && isValid=='0'){
		statusDetail ='交易成功';
		status='<div class="l mul"  style="'+ height  +'"><!--<div>'+'交易成功'+'</div>--><div><a href="'+detailUrl+'" target="_blank">订单详情</a><br /><a href="javascript:;" orderId="'+item.orderId+'" status="1"  class="cacelOrdelOrder"  target="_self">删除订单</a><br /><a href="'+expressUrl+'" target="_blank">查看物流</a></div></div>';
		outDelete ='<span class="r delete"><a orderId="'+item.orderId+'" status="1"  class="cacelOrdelOrder" target="_self" title="删除订单"><img src="'+rootPath+'/images/delete1.png" alt="" /></a></span>';
		sDetail = 'style="margin-left: 52%;"';
	}else if((payStatus == '1' || payStatus =='6') && shipStatus =='5' && isComment=='1' && isValid=='0'){
		statusDetail ='交易成功';
		status='<div class="l mul"  style="'+ height  +'"><!--<div>'+'交易成功'+'</div>--><div><a href="'+detailUrl+'"  target="_blank">订单详情</a><br /><a href="javascript:;" orderId="'+item.orderId+'" status="1"  class="cacelOrdelOrder"  target="_self">删除订单</a><br /><a href=""><a href="'+expressUrl+'" target="_blank">查看物流</a></div></div>';
		outDelete ='<span class="r delete"><a orderId="'+item.orderId+'" status="1"  class="cacelOrdelOrder" target="_self" title="删除订单"><img src="'+rootPath+'/images/delete1.png" alt="" /></a></span>';
		sDetail = 'style="margin-left: 52%;"';
	}else if(/*payStatus == '3' && shipStatus =='0' && isComment=='0' && */isValid=='1'){
		statusDetail ='交易关闭';
		status='<div class="l mul"  style="'+ height  +'"><!--<div>'+'交易关闭'+'</div>--><a href="javascript:;" orderId="'+item.orderId+'" status="1"  class="cacelOrdelOrder"  target="_self">删除订单</a></div>';
		outDelete ='<span class="r delete"><a orderId="'+item.orderId+'" status="1"  class="cacelOrdelOrder" target="_self" title="删除订单"><img src="'+rootPath+'/images/delete1.png" alt="" /></a></span>';
		sDetail = 'style="margin-left: 52%;"';
	}else{
		outDelete ='<span class="r delete"><a orderId="'+item.orderId+'" status="1"  class="cacelOrdelOrder" target="_self" title="删除订单"><img src="'+rootPath+'/images/delete1.png" alt="" /></a></span>';		
		sDetail = 'style="margin-left: 52%;"';
	}
	
	
	var str='<div class="items f12 clearfix">'
		+'<p class="nine">'
		+'<span class="nine">'+item.orderCreatTime+'</span>'
		+'<span class="three shop">'+item.shopName+'</span>'
		+'<span class="order status" '+sDetail+' >'+statusDetail+'</span>'
		+outDelete
	+'</p><div class="bord clearfix l">';

	var comment='';
	if((payStatus == '1' || payStatus =='6') && shipStatus =='5' && isComment=='0' && isValid=='0'){
		comment='<div class="r mul evaluate" style="'+ height  +'">';
	}else if((payStatus == '1' || payStatus =='6') && shipStatus =='5' && isComment=='1' && isValid=='0'){
		comment='<div class="r mul evaluate" style="'+ height  +'">';
	}
	$.each(productList,function(j,itemIn){
		var commentUrl = rootPath + "/order/comment?orderId="+item.orderId+"&productId="+itemIn.productId; //订单评价
		var addCommentUrl = rootPath + "/order/add_comment?orderId="+item.orderId+"&productId="+itemIn.productId; //订单追加评价
		var $unitPrice ="";
		var p1=parseFloat(itemIn.discountMarketPrice);
		var p2=parseFloat(itemIn.marketPrice);
		if(itemIn.discountMarketPrice){
			$unitPrice = '<div><!--<s>'+itemIn.marketPrice+'</s><br />--><span><i class="red">￥'+p1.toFixed(2)+'</i></span></div>';
		}else{
			$unitPrice = '<div><!--<s>'+itemIn.marketPrice+'</s><br />--><span><i class="red">￥'+p2.toFixed(2)+'</i></span></div>';
		}
		var price ="";
		if(itemIn.discountMarketPrice){
			price = itemIn.discountMarketPrice;
		}else{
			price = itemIn.marketPrice;
		}
		var goods_sku_info = '';
		if(itemIn.goods_sku_info){
			goods_sku_info = itemIn.goods_sku_info;
		}else{
			goods_sku_info ='无规格信息';
		}
		var first =  "";
		if(j == 0){
			first ="first";
		}
		//判断订单详细中商品评论状态
		if((payStatus == '1' || payStatus =='6') && shipStatus =='5' && itemIn.isComment=='0' && isValid=='0'){
			comment +='<div  class="'+first+'" style="height:120px;"><a href="'+commentUrl+'" target="_blank">立即评价</a></div>';
			
		}else if((payStatus == '1' || payStatus =='6') && shipStatus =='5' && itemIn.isComment=='1' && isValid=='0'){
				comment +='<div class="'+first+'" style="height:120px" >';
				if(itemIn.isCommentCount < 2){
					comment +='<a href="'+addCommentUrl+'" target="_blank">追加评价</a>';
				}
				comment +='</div>';		
		}
		var productDetailUrl = rootPath + "/goods/queryGoodsDetail?id=" + itemIn.productId;

		var picture  = rootPath+"/images/defualt.png";
		if(itemIn.picture){
			picture = itemIn.picture;
		}
		str+='<ul class="clearfix">'
					+'<li>'
						+'<div class="name clearfix">'
							 +'<a href="'+productDetailUrl+'"  target="_blank"><img style="width:80px; height:80px" src="'+picture+'" alt="" /></a>'
							 +'<div class="r">'
							      +'<a href="'+productDetailUrl+'"  target="_blank">'+itemIn.productName+'</a>'
								  +'<p class="f12 nine"><span>' + goods_sku_info + '</span></p>'
							 +'</div>'
						+'</div>'
						+$unitPrice
						+'<div>'+itemIn.quantity+'</div><div>'+item.memberName+'</div>'
					+'</li>'
				+'</ul>';
			
	});

	if((payStatus == '1' || payStatus =='6') && shipStatus =='5' && isComment=='0' && isValid=='0'){
		comment += "</div>"
	}else if((payStatus == '1' || payStatus =='6') && shipStatus =='5' && isComment=='1' && isValid=='0'){
		comment += "</div>"
	}
      var shipMoneyprice=parseFloat(item.shipMoney);
	var price02=parseFloat(item.totalAmount);
	str +='</div><div class="r mul_"  >'
		    + '<div class="l mul" style="'+ height  +'">'
			    + '<span class="price">￥'+price02.toFixed(2)+'</span><br />'
			    + '<span>(含运费：￥'+shipMoneyprice.toFixed(2)+')</span>'
			+ '</div>'
			+ status
		    +comment
			+ '</div>'
			+'</div>';
	
	return str;
};



